package com.carlinfo.common.util;

import java.util.Random;

public class RegexUtil
{
	private String allStr = "abcdefghijklmnopqrstuvwxyz0123456789";
	private String charStr = "abcdefghijklmnopqrstuvwxyz";
	private String numStr = "0123456789";
	
	public String proccedStr(int length,String type)
	{
		String randStr = allStr;
		if("0".equalsIgnoreCase(type))
		{
			randStr = allStr;
		}else if("1".equalsIgnoreCase(type))
		{
			randStr = charStr;
		}
		else if("2".equalsIgnoreCase(type))
		{
			randStr = numStr;
		}
		StringBuffer sb = new StringBuffer();
		Random random = new Random();
		for (int i = 0; i < length; i++)
		{
			int rand = random.nextInt(randStr.length());
			char ch = randStr.charAt(rand);
			sb.append(ch);
		}
		return sb.toString();
	}
	public static void main(String[] args)
	{
		RegexUtil regexUtil = new RegexUtil();
		String str = regexUtil.proccedStr(4, "2");
		System.out.println(str);
	}
}
